Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect CLJ_JVM_OPTS env var options when downloading clojure-tools #73

Merged
merged 2 commits into from
Oct 25, 2022

Conversation

ikappaki
Copy link
Contributor

@ikappaki ikappaki commented Oct 24, 2022

Hi,

can you please consider patch to try and download clojure tools archive via a java subprocess that respects the CLJ_JVM_OPTS environment variable. This addresses #66.

I have disabled the babashka tests because it can't recognise the new imported java.net.URLConnection symbol, would it be possible to add it to the babashka arsenal please if review is successful please?

5:   (:import [java.lang ProcessBuilder$Redirect]
     ^--- Unable to resolve classname: java.net.URLConnection

Changes are:

  1. The script will now attempt to download the clojure tools using the java executable first, fallback to direct download, and if that fails, display a message to the user where to copy the zip archive to. The java download methods requires Java11+/JEP-330.
  2. If the archive was there though (say the user copied it over), the tool will not try to download it again, but unzip it.
  3. An issue was identified in unzip with Filesystems/newFilesystem that was never closed (it is now in a with-open form).
  4. An inconsistency was identified that tools-dir was passed to clojure-tools-jar-download as a destination directory instead of libexec-dir.
  5. The HttpURLConnection is only set when downloading the clojure tools archive, if the src URL is http. For testing we use file:// where possible. This introduced the java.net.URLConnection symbol, but unfortunately it is not available in babashka and thus the bb tests have been temporarily disabled until this is resolved.
  6. Tests have been introduced to test all clojure tools download methodologies. A new dummy clojure tools archive is created on the fly when needed, and some java downloader tests only run when java > 11.
  7. Updated README.md mentioned the new env variables and other minor corrections.

Thanks,

src/borkdude/deps.clj Outdated Show resolved Hide resolved
src/borkdude/deps.clj Outdated Show resolved Hide resolved
src/borkdude/deps.clj Outdated Show resolved Hide resolved
@borkdude
Copy link
Owner

@ikappaki Beautiful PR, just a few minor comments.

For testing bb, I added java.net.URLConnection to bb now and you can get a dev build from:

https://github.com/babashka/babashka-dev-builds/releases/tag/v1.0.165-SNAPSHOT

You can install this with the installer script as well by providing a version with:

curl -sLO https://raw.githubusercontent.com/babashka/babashka/master/install
chmod +x ./install
./install --version 1.0.165-SNAPSHOT

Please update CI and turn bb tests back on.

1. Convert inline java program as a single string.
2. Simplify formatting of download msgs.
3. Only display a single msg while downloading, and only print out the
other message when new DEPS_CLJ_DBG env var is set.
4. Correct typos.
5. Update CI to use bb 1.0.165-SNAPSHOT for this review purposes and
restore bb tests in CI.
["-Xms256m"])))
(let [java-clj-jvm-opts (when clj-jvm-opts (vec (concat clj-jvm-opts
proxy-settings
["-Xms256m"])))]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the -Xms256m argument for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I picked it up from the clj-main-cmd a little bit further down the code, I assumed it was for some unknown to me use, shall I remove it?

@ikappaki
Copy link
Contributor Author

@ikappaki Beautiful PR, just a few minor comments.

For testing bb, I added java.net.URLConnection to bb now and you can get a dev build from:

https://github.com/babashka/babashka-dev-builds/releases/tag/v1.0.165-SNAPSHOT

You can install this with the installer script as well by providing a version with:

curl -sLO https://raw.githubusercontent.com/babashka/babashka/master/install
chmod +x ./install
./install --version 1.0.165-SNAPSHOT

Please update CI and turn bb tests back on.

Hi @borkdude,

I've addressed most of the review comments and updated the CI configs to use the babashka snapshot (markes as REVIEW) so as to run the babashka-test task. I'm ready to revert back to the normal babashka CI installation when you are ready to publish a new version.

In addition I've added some comments to the -main docstring about the use of the new variables, if you don't mind me intruding.

The only thing I haven't address is determining the java version, can you have a look at my reply and available options please?

Thanks,

@borkdude
Copy link
Owner

I think this looks good. I looked into the Xms256 thing and really can't find where this came from. This is the initial commit of the deps.clj script and it was already there. I think I'll just remove it since it isn't there in the clojure script either.

@borkdude borkdude merged commit 4417bb6 into borkdude:master Oct 25, 2022
@borkdude
Copy link
Owner

Much thanks!

ikappaki added a commit to ikappaki/deps.clj that referenced this pull request Nov 1, 2022
Replaces snapshot introduced in borkdude#73
@ikappaki ikappaki mentioned this pull request Nov 1, 2022
3 tasks
borkdude pushed a commit that referenced this pull request Nov 1, 2022
Replaces snapshot introduced in #73

Co-authored-by: ikappaki <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants